home *** CD-ROM | disk | FTP | other *** search
- /* Functions for handling events for system windows.
-
- 93/11/17 aih
- - desk accessories are closed in response to CMD_CLOSE
-
- 93/11/15 aih
- - added some utility functions
-
- 92/03/18 Ari Halberstadt (AIH)
- - Separated from main event handling code. */
-
- #include "EventLib.h"
- #include "MenuLib.h"
- #include "SystemWindowLib.h"
- #include "WindowLib.h"
-
- Boolean SystemIsActive(void)
- {
- WindowPtr front = FrontWindow();
- return(front && WinIsSystem(front) && WinVisible(front));
- }
-
- WindowPtr SystemWindowActive(void)
- {
- return(SystemIsActive() ? FrontWindow() : NULL);
- }
-
- short SystemWindowRefnum(WindowPtr window)
- {
- require(WinIsSystem(window));
- return(WinKind(window));
- }
-
- void SystemWindowClose(WindowPtr window)
- {
- require(! window || WinIsSystem(window));
- if (window)
- CloseDeskAcc(SystemWindowRefnum(window));
- }
-
- Boolean SystemDoMenu(const MenuPickType *pick)
- {
- Str255 name;
- GrafPtr port = NULL;
- Boolean handled = false;
-
- if (pick->cmd == CMD_APPLE) {
- GetPort(&port);
- GetItem(pick->menu, pick->item, name);
- OpenDeskAcc(name);
- SetPort(port);
- handled = true;
- }
- else if (SystemIsActive()) {
- switch (pick->cmd) {
- case CMD_UNDO:
- case CMD_CUT:
- case CMD_COPY:
- case CMD_PASTE:
- case CMD_CLEAR:
- handled = SystemEdit(pick->item - 1);
- break;
- case CMD_CLOSE:
- SystemWindowClose(SystemWindowActive());
- handled = true;
- break;
- }
- }
- return(handled);
- }
-
- void SystemAdjustMenu(void)
- {
- if (SystemIsActive()) {
- MenuCmdEnable(CMD_EDIT);
- MenuCmdEnable(CMD_UNDO);
- MenuCmdEnable(CMD_CUT);
- MenuCmdEnable(CMD_COPY);
- MenuCmdEnable(CMD_PASTE);
- MenuCmdEnable(CMD_CLEAR);
- MenuCmdEnable(CMD_CLOSE);
- }
- }
-